from pydantic_settings import BaseSettings
import os
from pathlib import Path

class Settings(BaseSettings):
    """应用配置"""
    # TCP 服务器配置
    tcp_host: str = "192.168.6.224"
    tcp_port: int = 7910
    tcp_timeout: int = 5  # 修改为5秒
    tcp_buffer_size: int = 1024
    
    # 商户配置
    default_merno: str = "999999999999997"  # 商户号
    default_terminal: str = "99999996"      # 终端号
    
    # 日志配置
    log_level: str = "INFO"
    log_format: str = "%(asctime)s [%(levelname)s] [%(name)s] %(message)s"
    log_dir: str = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "logs")
    log_max_size: int = 10 * 1024 * 1024  # 10MB
    log_backup_count: int = 5

    class Config:
        env_file = ".env"

# 创建日志目录
Path(Settings().log_dir).mkdir(parents=True, exist_ok=True)

settings = Settings() 